﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Wekit.Web.Security;
using Wekit.Repository.Auth;
namespace Wekit.Web.Services
{
    public  class PrincipalService : IPrincipalService
    {
        public IUserRepository UserRepository { get; set; }

        public Model.Auth.User createUser(Model.Auth.User user)
        {
           return UserRepository.addUser(user);
        }

        public Model.Auth.User createUser(string userId,string userName, string password, string email)
        {
            Model.Auth.User user = new Model.Auth.User();
            user.UserId = userId;
            user.Password = password;
            user.Email = email;
            return  this.createUser(user);
        }

        public Model.Auth.User createUser(string userId,  string password, string email)
        {
            return createUser(userId,"匿名" ,password, email);
        }


        /// <summary>
        /// 根据注册对象创建实体用户
        /// </summary>
        /// <param name="model">注册模型</param>
        /// <returns></returns>
        public Model.Auth.User createUser(Models.RegisterModel model)
        {
            Model.Auth.User user = new Model.Auth.User();
            user.Email = model.Email;
            user.Name = model.UserName;
            user.UserId = model.UserId;
            user.Password = model.Password;
            return createUser(user);
        }
    }
}
